package main

import (
	"github.com/gin-gonic/gin"
	"note.zhiwangyunchuang.com/controller"
	"note.zhiwangyunchuang.com/middleware"
)

func CollectRoute(r *gin.Engine) *gin.Engine {
	r.Use(middleware.CORSMiddleware())
	rote := r.Group("/v1")
	{
		// 笔记
		noteGroup := rote.Group("/note", middleware.AuthMiddleware())
		{
			//r.Use(middleware.AuthMiddleware())
			// 详情
			noteGroup.GET("/:id", controller.NoteInfo)
			// 修改
			noteGroup.PUT("/:id", controller.NoteEdit)
			// 删除
			noteGroup.DELETE("/:id", controller.NoteDel)
			// 增加
			noteGroup.POST("", controller.NoteAdd)
			// 列表
			noteGroup.GET("", controller.NoteList)
			// 上传音频
			noteGroup.POST("/upload", controller.UpAudio)
			// 识别语音
			noteGroup.POST("/identify", controller.IdentifyAudio)
		}
		// 用户
		userGroup := rote.Group("/user")
		{
			// 注册
			userGroup.POST("/register", controller.Register)
			// 登录
			userGroup.POST("/login", controller.Login)
		}
	}
	return r
}
